import request from '@u/request';

const MENU_API_HOST = '/api/admin/permission'; //菜单相关接口
const DICTIONARY_API_HOST = '/api/admin/dictionary'; //字典相关接口
const SYSTEM_USERS_HOST = '/api/admin/manager';//系统用户
const ROLES_HOST = '/api/admin/role'; //角色
const WECHAT_MENU_API_HOST = '/api/admin/weChat/menu'

const system = {
    //获取登录验证码
    getLoginCode : params => {
        return request({
			url : '/api/admin/utility/captcha',
			params,
			method : 'GET'
		})
    },
    //登录
    login : data => {
        return request({
			url : `${SYSTEM_USERS_HOST}/login`,
			data,
			method : 'POST'
		})
    },
	//修改登录账户密码
	changePwd : data => {
		return request({
			url : `${SYSTEM_USERS_HOST}/password`,
			data,
			method : 'put'
		})
	},
    //获取系统用户信息
    getUserInfo : params => {
        return request({
			url : `${SYSTEM_USERS_HOST}/info`,
			params,
			method : 'get',
		})
    },
    //获取用户菜单
    getMenu : params => {
        return request({
			url : '/api/admin/role/permission',
			params,
			method : 'GET'
		})
    },
	//获取菜单列表
	menuList : params => {
		return request({
			url : MENU_API_HOST,
			params,
			method : 'GET'
		})
	},
	//删除菜单
	menuDelete : params => {
		return request({
			url : MENU_API_HOST,
			params,
			method : 'delete'
		})
	},
	//添加菜单
	menuCreate : data => {
		return request({
			url : MENU_API_HOST,
			data,
			method : 'post'
		})
	},
	//菜单更新
	menuUpdate : data => {
		return request({
			url : MENU_API_HOST,
			data,
			method : 'put'
		})
	},
	//字典列表
	dictionaryList : params => {
		return request({
			url : DICTIONARY_API_HOST,
			params,
			method : 'GET'
		})
	},
	//删除字典
	dictionaryDelete : params => {
		return request({
			url : DICTIONARY_API_HOST,
			params,
			method : 'delete'
		})
	},
	//添加字典
	dictionaryCreate : data => {
		return request({
			url : DICTIONARY_API_HOST,
			data,
			method : 'post'
		})
	},
	//字典更新
	dictionaryUpdate : data => {
		return request({
			url : DICTIONARY_API_HOST,
			data,
			method : 'put'
		})
	},
	//系统用户列表
	usersList : params => {
		return request({
			url : SYSTEM_USERS_HOST,
			params,
			method : 'get'
		})
	},
	//创建系统用户
	usersCreate : data => {
		return request({
			url : SYSTEM_USERS_HOST,
			data,
			method : 'post'
		})
	},
	//更新系统用户
	usersUpdate : data => {
		return request({
			url : SYSTEM_USERS_HOST,
			data,
			method : 'put'
		})
	},
	//删除系统用户
	usersDelete : params => {
		return request({
			url : SYSTEM_USERS_HOST,
			params,
			method : 'delete'
		})
	},
	//角色列表
	rolesList : params => {
		return request({
			url : ROLES_HOST,
			params,
			method : 'get'
		})
	},
	//角色删除
	rolesDelete : params => {
		return request({
			url : ROLES_HOST,
			params,
			method : 'delete'
		})
	},
	//角色创建
	rolesCreate : data => {
		return request({
			url : ROLES_HOST,
			data,
			method : 'post'
		})
	},
	//角色更新
	rolesUpdate : data => {
		return request({
			url : ROLES_HOST,
			data,
			method : 'put'
		})
	},
	//为角色分配权限
	rolesPermission : data => {
		return request({
			url : `${ROLES_HOST}/permission`,
			data,
			method : 'put'
		})
	},
	//获取全部角色
	rolesAll : params => {
		return request({
			url : `/api/admin/manager/role`,
			params,
			method : 'get'
		})
	},

	//微信菜单列表
    wechatMenuList : params => {
        return request({
			url : WECHAT_MENU_API_HOST,
			params,
			method : 'GET'
		})
    },
	//微信菜单删除
    wechatMenuDelete : params => {
        return request({
			url : WECHAT_MENU_API_HOST,
			params,
			method : 'delete'
		})
    },
    //微信菜单创建
    wechatMenuCreate : data => {
        return request({
			url : WECHAT_MENU_API_HOST,
			data,
			method : 'post'
		})
    },
    //微信菜单更新
    wechatMenuUpdate : data => {
        return request({
			url : WECHAT_MENU_API_HOST,
			data,
			method : 'put'
		})
    },
    //生成微信菜单
    wechatMenuCreateRemote : data => {
        return request({
			url : `/api/admin/weChat/submit`,
			data,
			method : 'put'
		})
    },
}

export default system;